package edu.cuit.canary.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/8/14 14:40
 */
@Controller
public class WelcomeController {

    @RequestMapping("/welcome")
    public ModelAndView welcome(){
        var mv = new ModelAndView();
        //绑定模型数据,将其设置进request共享作用域对象中 request.setAttribute("welcome", "welcome to spring mvc")
        mv.addObject("welcome", "welcome to spring mvc");
        //设置逻辑视图名 (视图名 = prefix + name + suffix)
        mv.setViewName("welcome"); // /WEB-INF/pages/welcome.jsp // request.getRequestDispatcher("/WEB-INF/pages/welcome.jsp").forward(request,response)
        //将ModelAndView返回给DispatcherServlet
        return mv;
    }
}
